using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using DAL;
using BUS;
using Utility;

public partial class Admin_DoanhNghiepUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }

    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbDoanhNghiep dn = tbDoanhNghiepBus.GetByID(id);
            if (dn != null)
            {
                txt_madn.Text = dn.IDDoanhNghiep.ToString();
                txt_tendn.Text = dn.TenDoanhNghiep;
                txt_dc.Text = dn.DiaChi;
                txt_dt.Text = dn.DienThoai;
                txt_email.Text = dn.Email;
            }
        }
        catch
        {
            Response.Redirect("~/Admin/DoanhNghiepList.aspx");
        }
    }
    protected void btdd_update_Click(object sender, EventArgs e)
    {
        tbDoanhNghiep dn = new tbDoanhNghiep();
        dn.IDDoanhNghiep = int.Parse(txt_madn.Text);
        dn.TenDoanhNghiep = txt_tendn.Text;
        dn.DiaChi = txt_dc.Text;
        dn.DienThoai = txt_dt.Text;
        dn.Email = txt_email.Text;
        tbDoanhNghiepBus.Update_DoanhNghiep(dn);
        Response.Redirect("~/Admin/DoanhNghiepList.aspx");
    }
}
